<?php
/**
 * 删除岗位
 * @author ray
 */
apf_require_controller("HrAbstract");

class Hr_Ajax_DeleteJobController extends HrAbstractController {

    public function handle_request() {
        $params = $this->request->get_parameters();

        $status=0;
        //检测参数合法性
        $this->_check_params($params);
        $job_bll = new Bll_Hr_Job();

        $job_data=$job_bll->find_by_job_id($params['jobID']);
        if(empty($job_data)){
            $this->json_encode($status,Const_Tip::ERROR_JOB_NOT_EXISTS);
        }
        if($job_data['fact_num']){
            $this->json_encode($status,Const_Tip::ERROR_JOB_HAS_PEOPLE);
        }
        $result = $job_bll->update_status_by_id($params['jobID'], 2);
        if($result !== false){
            $status = 1;
            $this->json_encode($status,$result);
        }else{
            $this->json_encode($status,Const_Tip::ERROR_JOB_DB);
        }

    }
    /**
     * 参数检测
     */
    private function _check_params($params){
        $status = 0;
        if(empty($params['jobID'])){
            $this->json_encode($status,Const_Tip::ERROR_PARAM);
        }
    }
}